﻿using LiveChartsCore.Drawing;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
using Nlnet.Avalonia.Controls;
using OfficeOpenXml;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 畜牧业审核程序国产.Models.ToolsClass;
using 畜牧业审核程序国产.Models;
using LiveChartsCore.SkiaSharpView.VisualElements;
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using 畜牧业审核程序国产.Models.DataGridMsgs;
using MsBox.Avalonia.Enums;
using System.IO;
using System.Reflection;
using static System.Runtime.InteropServices.JavaScript.JSType;
using OfficeOpenXml.Drawing.Slicer.Style;

namespace 畜牧业审核程序国产.ViewModels
{
    internal class Page7A406ViewModel : MyViewModelBase
    {
        #region 声明一定要用的字段
        private readonly string WithYSA406NameNow = "一套表" + Global.StrYearNow + Global.StrSeasonNow + "A406";
        private readonly string WithYSA406NamePre = "一套表" + Global.StrYearPre + Global.StrSeasonPre + "A406";
        private readonly string WithYSA406NameYOY = "一套表" + Global.StrYearYOY + Global.StrSeasonYOY + "A406";
        private string WithYSA406NameSpring = "一套表" + Global.StrYearNow + "第一季度A406";
        private string WithYSA406NameSummer = "一套表" + Global.StrYearNow + "第二季度A406";
        private string SpringPlatform
        {
            get
            {
                if (Global.IntYearNow > 2025)
                {
                    return "统计云";
                }
                else
                {
                    return "一套表";
                }
            }
        }
        private string SummerPlatform
        {
            get
            {
                if (Global.IntYearNow > 2025)
                {
                    return "统计云";
                }
                else
                {
                    return "一套表";
                }
            }
        }


        string[] ArrStrAllIndicatorsBeShowedOfA406 = new string[] {"存栏头数（含未断奶小猪）01",
            "能繁殖的母猪02","生猪出栏头数03","牛存栏头数04","良种及改良种乳牛05","牛出栏头数06",
            "羊存栏只数07","羊出栏只数08","家禽存栏只数09","家禽出栏只数10","兔存栏只数11","兔出栏只数12",
            "肉类产量13","猪  肉14","牛  肉15","羊  肉16","禽  肉17","兔  肉18","其  它19","鸡鸭鹅蛋产量20",
            "生牛奶产量21","蚕茧产量22","鸡存栏23","鸡出栏24"
        };
        #endregion

        #region 声明属性


        #region 声明用户选择了以后,selectedItem关联的 SelectedValue的属性或selectedItem.selectedItem是键值对,而selectedValue是键值对的值,配合selectedValuePath使用

        private KeyValuePair<string, string> _selectedCity;
        public KeyValuePair<string, string> SelectedCity
        {
            get { return _selectedCity; }
            set
            {
                SetProperty(ref _selectedCountry, value);
                //当用户选择了市以后,就要把县展现出来了
                //县可以包含"全部"
                if (value.Value != null)
                {
                    MyDBOperator dBOperator = MyDBOperator.DBOperatorInstance;

                    if (value.Value.Equals("全部"))//市这里选择了"全部",相当于要展示所有地市的情况
                    {
                        //
                        CountryCln.Clear();
                        CountryCln.Add(new KeyValuePair<string, string>("0", "全部"));
                        SelectedCountry = new KeyValuePair<string, string>("change", "change");
                        SelectedCountry = CountryCln[0];
                    }
                    else if (value.Key.Equals("0"))
                    {
                        return;
                    }
                    else//如果市这里选择的不是全部,而是某个具体的市,那么要把所有县和"全部"一起作为countryCln的值
                    {

                        string sqlForGetCountry = $"select 县代码,县 from {WithYSA406NameNow} where 市代码  = '{value.Key}' group by 县代码,县";
                        DataTable dt = dBOperator.GetDataTable(sqlForGetCountry);
                        if (dt.Rows.Count == 0 || dt == null)
                        {
                            CountryCln.Clear();
                            CountryCln.Add(new KeyValuePair<string, string>("0", "未导入A406表或A406表导入错误"));
                            SelectedCountry = new KeyValuePair<string, string>("change", "change");
                            SelectedCountry = CountryCln[0];
                            return;
                        }
                        CountryCln.Clear();
                        CountryCln.Add(new KeyValuePair<string, string>("0", "全部"));
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            DataRow dtRow = dt.Rows[i];
                            CountryCln.Add(new KeyValuePair<string, string>(dtRow[0].ToString(), dtRow[1].ToString()));
                        }
                        SelectedCountry = new KeyValuePair<string, string>("change", "change");
                        SelectedCountry = CountryCln[0];
                    }
                }
                SetProperty(ref _selectedCity, value);
            }
        }
        private KeyValuePair<string, string> _selectedCountry;

        public KeyValuePair<string, string> SelectedCountry
        {
            get { return _selectedCountry; }
            set
            {
                SetProperty(ref _selectedCountry, value);
                //if (Regex.IsMatch(value.Value, "全部"))
                //{
                //    TownCln.Clear();
                //    TownCln.Add(new KeyValuePair<string, string>("0", "全部"));
                //    SelectedTown = TownCln[0];
                //}
                //else//如果县这里选择的不是全部,而是某个具体的县,那么要把所有乡镇和"全部"一起作为townCln的值
                //{
                //    ADOdotnet aDOdotnet = new ADOdotnet();
                //    string sql = $"select 乡镇代码,乡 from {WithYSA406NameNow} WHERE 县代码 = '{SelectedCountry.Key}' group by 乡镇代码,乡";
                //    DataTable dt = aDOdotnet.GetDataTable(sql);
                //    if (dt == null || dt.Rows.Count == 0)
                //    {
                //        TownCln.Clear();
                //        TownCln.Add(new KeyValuePair<string, string>("0", "未导入A406表或A2406表导入错误"));
                //        return;
                //    }
                //    TownCln.Clear();
                //    TownCln.Add(new KeyValuePair<string, string>("0", "全部"));
                //    for (int i = 0; i < dt.Rows.Count; i++)
                //    {
                //        DataRow dtRow = dt.Rows[i];
                //        TownCln.Add(new KeyValuePair<string, string>(dtRow[0].ToString(), dtRow[1].ToString()));

                //    }
                //    SelectedTown = TownCln[0];

                //}
                //SetProperty(ref _selectedCountry, value);
            }
        }
        private KeyValuePair<string, string> _selectedTown;

        public KeyValuePair<string, string> SelectedTown
        {
            get { return _selectedTown; }
            set
            {
                SetProperty(ref _selectedTown, value);
                //if (value.Value.Equals("全部")==false)
                //{
                //    isShowAllOwnerMsgEnableForTown = false;
                //}
                //else
                //{
                //    isShowAllOwnerMsgEnableForTown=true;
                //}
            }
        }
        private KeyValuePair<string, string> _selectedIndicator;

        public KeyValuePair<string, string> SelectedIndicator
        {
            get { return _selectedIndicator; }
            set { SetProperty(ref _selectedIndicator, value); }
        }
        private KeyValuePair<string, string> _canBePieOrCartIndicator;


        #endregion
        #region 用户选择的期别

        private ObservableCollection<string> _period = new ObservableCollection<string>();
        public ObservableCollection<string> Period
        {
            get => _period;
            set
            {
                SetProperty(ref _period, value);
            }
        }
        private void SetPeroid()
        {
            if (Global.IntSeasonNow == 1)
            {
                this.Period.Add("本季度");
            }
            else
            {
                this.Period.Add("本季度");
                this.Period.Add("一到本季度");
            }
        }

        private string _selectedPeriod;
        public string SelectedPeriod
        {
            get { return _selectedPeriod; }
            set { SetProperty(ref _selectedPeriod, value); }
        }
        #endregion
        //#region 绑定到datagrid的DataTable
        //private DataTable _dtForAll;

        //public DataTable DtForAll
        //{
        //    get { return _dtForAll; }
        //    set { SetProperty(ref _dtForAll, value); }
        //}
        //private DataTable _dtSingleIndicator;

        //public DataTable DtForSingleIndicator
        //{
        //    get { return _dtSingleIndicator; }
        //    set { SetProperty(ref _dtSingleIndicator, value); }
        //}


        //#endregion
        #region 属性--为了解决livechart2中文乱码的问题,在父类里写过了,这里反而是画蛇添足
        //private double _fontSize;
        //public double FontSize
        //{
        //    get => _fontSize;
        //    set { SetProperty(ref _fontSize, value); }
        //}

        //private IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> _textPaint;

        //public IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> TextPaint { get => _textPaint; set => SetProperty(ref _textPaint, value); }


        //private IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> _textPaint2;
        //public IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> TextPaint2
        //{
        //    get => _textPaint2; set { SetProperty(ref _textPaint2, value); }
        //}

        #endregion
        #region 小饼图(散户饼图)
        private LabelVisual _titleOfPieSeriesSmallNow;

        public LabelVisual TitleOfPieSeriesSmallNow
        {
            get { return _titleOfPieSeriesSmallNow; }
            set => SetProperty(ref _titleOfPieSeriesSmallNow, value);
        }
        private LabelVisual _titleOfPieSeriesSmallPre;

        public LabelVisual TitleOfPieSeriesSmallPre
        {
            get { return _titleOfPieSeriesSmallPre; }
            set => SetProperty(ref _titleOfPieSeriesSmallPre, value);
        }
        private LabelVisual _titleOfPieSeriesSmallYOY;

        public LabelVisual TitleOfPieSeriesSmallYOY
        {
            get { return _titleOfPieSeriesSmallYOY; }
            set => SetProperty(ref _titleOfPieSeriesSmallYOY, value);
        }

        private ISeries[] _pieSeriesOfSmallYOY;
        public ISeries[] PieSeriesOfSmallYOY
        {
            get => _pieSeriesOfSmallYOY;
            set { SetProperty(ref _pieSeriesOfSmallYOY, value); }
        }
        private ISeries[] _pieSeriesOfSmallPre = new ISeries[] { };
        public ISeries[] PieSeriesOfSmallPre
        {
            get => _pieSeriesOfSmallPre;
            set => SetProperty(ref _pieSeriesOfSmallPre, value);
        }

        private ISeries[] _pieSeriesOfSmallNow = new ISeries[] { };
        public ISeries[] PieSeriesOfSmallNow
        {
            get => _pieSeriesOfSmallNow;
            set => SetProperty(ref _pieSeriesOfSmallNow, value);
        }

        #endregion
        #region 小直方图(散户直方图)
        private LabelVisual _titleOfCartSmallYOY;//同比直方图的标题

        public LabelVisual TitleOfCartSmallYOY
        {
            get { return _titleOfCartSmallYOY; }
            set => SetProperty(ref _titleOfCartSmallYOY, value);
        }
        private LabelVisual _titleOfCartSmallPre;//环比直方图的标题

        public LabelVisual TitleOfCartSmallPre
        {
            get { return _titleOfCartSmallPre; }
            set => SetProperty(ref _titleOfCartSmallPre, value);
        }
        private LabelVisual _titleOfCartSmallNow;//环比直方图的标题

        public LabelVisual TitleOfCartSmallNow
        {
            get { return _titleOfCartSmallNow; }
            set => SetProperty(ref _titleOfCartSmallNow, value);
        }
        private ISeries[] _cartSeriesSmallYOY;//同比直方图的内容

        public ISeries[] CartSeriesSmallYOY
        {
            get { return _cartSeriesSmallYOY; }
            set => SetProperty(ref _cartSeriesSmallYOY, value);
        }
        private ISeries[] _cartSeriesSmallPre;//环比直方图的内容

        public ISeries[] CartSeriesSmallPre
        {
            get { return _cartSeriesSmallPre; }
            set => SetProperty(ref _cartSeriesSmallPre, value);
        }
        private ISeries[] _cartSeriesSmallNow;//现在直方图的内容

        public ISeries[] CartSeriesSmallNow
        {
            get { return _cartSeriesSmallNow; }
            set => SetProperty(ref _cartSeriesSmallNow, value);
        }

        private Axis[] _cartXAxisOfSmallYOY;//同比直方图季度x轴

        public Axis[] CartXAxisOfSmallYOY
        {
            get { return _cartXAxisOfSmallYOY; }
            set { SetProperty(ref _cartXAxisOfSmallYOY, value); }
        }
        private Axis[] _cartYAxisOfSmallYOY;//同比直方图季度Y轴

        public Axis[] CartYAxisOfSmallYOY
        {
            get { return _cartYAxisOfSmallYOY; }
            set { SetProperty(ref _cartYAxisOfSmallYOY, value); }
        }


        private Axis[] _cartXAxisOfSmallPre;//环比直方图季度x轴

        public Axis[] CartXAxisOfSmallPre
        {
            get { return _cartXAxisOfSmallPre; }
            set { SetProperty(ref _cartXAxisOfSmallPre, value); }
        }
        private Axis _cartYAxisOfSmallPre;//同比直方图季度Y轴

        public Axis CartYAxisOfSmallPre
        {
            get { return _cartYAxisOfSmallPre; }
            set { SetProperty(ref _cartYAxisOfSmallPre, value); }
        }


        private Axis[] _cartXAxisOfSmallNow;//现在直方图季度x轴

        public Axis[] CartXAxisOfSmallNow
        {
            get { return _cartXAxisOfSmallNow; }
            set { SetProperty(ref _cartXAxisOfSmallNow, value); }
        }
        private Axis[] _cartYAxisOfSmallNow;//现在直方图季度Y轴

        public Axis[] CartYAxisOfSmallNow
        {
            get { return _cartYAxisOfSmallNow; }
            set { SetProperty(ref _cartYAxisOfSmallNow, value); }
        }









        #endregion
        #region 小折线图(散户折线图)
        private ISeries[] _lineSeriesSmall;

        public ISeries[] LineSeriesSmall
        {
            get { return _lineSeriesSmall; }
            set => SetProperty(ref _lineSeriesSmall, value);
        }

        private Axis[] _lineXAxisSmall;//折线图x轴

        public Axis[] LineXAxisSmall
        {
            get { return _lineXAxisSmall; }
            set { SetProperty(ref _lineXAxisSmall, value); }
        }
        private Axis[] _lineYAxisSmall;//折线图Y轴

        public Axis[] LineYAxisSmall
        {
            get { return _lineYAxisSmall; }
            set { SetProperty(ref _lineYAxisSmall, value); }
        }
        private LabelVisual _LineTltleSmall;

        public LabelVisual LineTitleSmall
        {
            get { return _LineTltleSmall; }
            set => SetProperty(ref _LineTltleSmall, value);
        }
        #endregion
        Models.ShowMsg showMsg;
        Models.ShowA406Msg showA406Msg;
        #endregion

        #region 构造函数
        /// <summary>
        /// 构造函数里面只写好命令和showmsg,然后获取到
        /// </summary>
        public Page7A406ViewModel()
        {
            #region 初始化命令
            showMsg = new Models.ShowMsg();
            showA406Msg = new ShowA406Msg();
            this.ShowAllMsgCommand = new RelayCommand(async () => await ShowAllMsgsAsync());
            this.ShowSingleMsgCommand = new RelayCommand(async () => { await ShowSingleMsgAsync(); });
            this.AllExpertToExcelCommand = new RelayCommand(async () => await ExpertToExcelAll());
            SingleExpertToExcelCommand = new RelayCommand(async () => await ExpertToExcelSingle());
            this.QueryFrom1ToNewTableInDBCommand = new RelayCommand(() => ShowFrom1ToNowTablesInDB());
            // this.SingleOutCommand = new RelayCommand(() => { SingleOut(); });
            SetPeroid();
            #endregion

            try
            {
                MyDBOperator myDbOperator = MyDBOperator.DBOperatorInstance;
                if (myDbOperator.CheckIfTableExists(WithYSA406NameNow) == false)
                {
                    CityCln.Clear();
                    CityCln.Add(new KeyValuePair<string, string>("0", $"未导入{WithYSA406NameNow},或导入错误"));
                    return;
                }
                CityCln = showMsg.GetAllCityItems(WithYSA406NameNow);
                #region 在最后一个下拉框中显示所有的指标
                LoadAllIndicators();
                #endregion
                ////这里务必要先判断一下表是否存在
                //string[] allNeedTables = new string[] { WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameYOY };
                //var mydbOperatorInstanceperator = MyDBOperator.DBOperatorInstance;
                //var notExistsA406Tables = mydbOperatorInstanceperator.CheckTablesExist(allNeedTables);
                //string allNotExistTablesJoin = null;
                //if (notExistsA406Tables.Count > 0)
                //{
                //    for (int i = 0; i < notExistsA406Tables.Count; i++)
                //    {
                //        allNotExistTablesJoin += $"、{notExistsA406Tables[i].Substring(3)}";
                //    }
                //    allNotExistTablesJoin = allNotExistTablesJoin.Substring(1);
                //     MyMessagebox.Show(allNotExistTablesJoin + "不存在,请先导入");
                //    return;

                //}
                ////检查一下是否已经进行了数据修正
                //List<bool> istableCorrected = new List<bool>();



                //istableCorrected.Add(IsCorrected(WithYSA406NameNow));
                //istableCorrected.Add(IsCorrected(WithYSA406NamePre));
                //istableCorrected.Add(IsCorrected(WithYSA406NameYOY));
                //if (istableCorrected.Contains(false))
                //{
                //    MyMessagebox.Show("可能存在部分养殖户市、县、乡名称填写不规范的情况，本程序内置了2022年省统计局下发的统计区划代码，" + "\r\n" + "强烈建议在“审核数据界面”进行数据修正（耗时2分钟左右）后再查看各畜种数据情况，否则可能显示不正确");
                //}
            }
            catch (Exception ex)
            {
                StaticLogger.SystemError($"出现错误,错误内容为{ex.Message}");
                throw;
            }

        }

        #region 临时增加的
        private DataTable GetTtableMsgs(string[] tables)
        {
            MyDBOperator getTableMsgOperator = MyDBOperator.DBOperatorInstance;
            DataTable DTOfTableMsgs = getTableMsgOperator.GetDataTable("select 表名称,导入时间,已导入的户数 from DataTable要用的字段 "); //手动创建的datatable显示不了,这里是获取标题
            // DTOfTableMsgs = new DataTable();
            //DTOfTableMsgs.Columns.Add("表名", typeof(string));
            //DTOfTableMsgs.Columns.Add("导入时间", typeof(string));
            foreach (string tablename in tables)
            {
                int rowcount;
                string TableCreateTime = getTableMsgOperator.ReturnTableCreateTimeAndRowCount(tablename, out rowcount);
                DataRow tableMsgRow = DTOfTableMsgs.NewRow();
                tableMsgRow[0] = tablename;
                tableMsgRow[1] = TableCreateTime;
                tableMsgRow[2] = rowcount;
                DTOfTableMsgs.Rows.Add(tableMsgRow);
            }

            //DTOfTableMsgs.Columns[0].ColumnName = "表名";
            //DTOfTableMsgs.Columns[1].ColumnName = "是否导入";
            return DTOfTableMsgs;
        }

        private void ShowFrom1ToNowTablesInDB()
        {
            string[] allNeedTables = null;
            if (Global.IntSeasonNow == 1)
            {
                return;
            }

           
                if (Global.IntSeasonNow == 2)
                {
                    //先判断一下表是否存在
                    string WithYearSeasonA209NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                    string WithYearSeasonA210NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                    string WithYearSeasonA211NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                    string WithYearSeasonA212NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                    string WithYearSeasonA209NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                    string WithYearSeasonA210NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                    string WithYearSeasonA211NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                    string WithYearSeasonA212NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";


                    allNeedTables = new string[]
                    {
                        WithYearSeasonA209NameNow, WithYearSeasonA209NamePre, WithYearSeasonA210NameNow,
                        WithYearSeasonA210NamePre,
                        WithYearSeasonA211NameNow, WithYearSeasonA211NamePre, WithYearSeasonA212NameNow,
                        WithYearSeasonA212NamePre, WithYSA406NameNow, WithYSA406NamePre
                    };
                }
                else if (Global.IntSeasonNow == 3)
                {
                    //先判断一下表是否存在
                    string WithYearSeasonA209NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                    string WithYearSeasonA210NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                    string WithYearSeasonA211NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                    string WithYearSeasonA212NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                    string WithYearSeasonA209NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                    string WithYearSeasonA210NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                    string WithYearSeasonA211NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                    string WithYearSeasonA212NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                    string WithYearSeasonA209NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A209";
                    string WithYearSeasonA210NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A210";
                    string WithYearSeasonA211NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A211";
                    string WithYearSeasonA212NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A212";


                    allNeedTables = new string[]
                    {
                        WithYearSeasonA209NameNow, WithYearSeasonA209NamePre,  WithYearSeasonA209NameSpring,
                        WithYearSeasonA210NameNow, WithYearSeasonA210NamePre, WithYearSeasonA210NameSpring,
                        WithYearSeasonA211NameNow, WithYearSeasonA211NamePre, WithYearSeasonA211NameSpring,
                        WithYearSeasonA212NameNow, WithYearSeasonA212NamePre,WithYearSeasonA212NameSpring,
                        WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameSpring
                    };
                }
                else if (Global.IntSeasonNow == 4)
                {
                    string WithYearSeasonA209NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                    string WithYearSeasonA210NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                    string WithYearSeasonA211NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                    string WithYearSeasonA212NameNow =
                        Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                    string WithYearSeasonA209NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                    string WithYearSeasonA210NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                    string WithYearSeasonA211NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                    string WithYearSeasonA212NamePre =
                        Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                    string WithYearSeasonA209NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A209";
                    string WithYearSeasonA210NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A210";
                    string WithYearSeasonA211NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A211";
                    string WithYearSeasonA212NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A212";
                    string WithYearSeasonA209NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A209";
                    string WithYearSeasonA210NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A210";
                    string WithYearSeasonA211NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A211";
                    string WithYearSeasonA212NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A212";


                   allNeedTables = new string[]
                    {
                        WithYearSeasonA209NameNow, WithYearSeasonA209NamePre,WithYearSeasonA209NameSummer,  WithYearSeasonA209NameSpring,
                        WithYearSeasonA210NameNow, WithYearSeasonA210NamePre, WithYearSeasonA210NameSummer, WithYearSeasonA210NameSpring,
                        WithYearSeasonA211NameNow, WithYearSeasonA211NamePre,   WithYearSeasonA211NameSummer, WithYearSeasonA211NameSpring,
                        WithYearSeasonA212NameNow, WithYearSeasonA212NamePre, WithYearSeasonA212NameSummer, WithYearSeasonA212NameSpring,
                        WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameSpring, WithYSA406NameSummer
                    };
                }

                //检查这几张表的情况,并在单独一个窗口中显示
                DataTable dtOfTableMsgs = GetTtableMsgs(allNeedTables);
                if (dtOfTableMsgs != null && dtOfTableMsgs.Rows.Count > 0)
                {
                    FromSpringToNowTableMsgs window = new FromSpringToNowTableMsgs(dtOfTableMsgs);

                    window.Show();
                }
            
        }

        #endregion
        private async Task<bool> CheckAllA406ExistsAsync()
        {
            string[] allNeedTables = new string[] { WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameYOY };
            var mydbOperatorInstanceperator = MyDBOperator.DBOperatorInstance;
            var notExistsA406Tables = mydbOperatorInstanceperator.CheckTablesExist(allNeedTables);
            string allNotExistTablesJoin = null;
            if (notExistsA406Tables.Count > 0)
            {
                for (int i = 0; i < notExistsA406Tables.Count; i++)
                {
                    allNotExistTablesJoin += $"、{notExistsA406Tables[i].Substring(3)}";
                }
                allNotExistTablesJoin = allNotExistTablesJoin.Substring(1);
                await MyMessagebox.ShowAsyncInMainWindow(allNotExistTablesJoin + "不存在,请先导入", Icon.Warning);
                return true;

            }

            return false;
        }

        private void AllOut()
        {

        }
        public void ExportDataTableToExcel(DataTable DT, string FilePath)
        {
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (var package = new ExcelPackage())
            {
                var sht = package.Workbook.Worksheets.Add("Sheet1");
                sht.Cells["A1"].LoadFromDataTable(DT, true);
                package.SaveAs(new System.IO.FileInfo(FilePath));
            }
        }
        //private void GetCityItems()
        //{
        //    ADOdotnet adoForGetCity = new ADOdotnet();
        //    string sqlForGetCity = $"select 市代码,市 from {WithYSA406NameNow} group by 市代码,市";
        //    DataTable dt = adoForGetCity.GetDataTable(sqlForGetCity);
        //    if (dt.Rows.Count == 0 || dt == null)
        //    {
        //        CityCln.Clear();
        //        CityCln.Add(new KeyValuePair<string, string>("0", "未导入A406表或A406表导入错误"));
        //        return;
        //    }
        //    CityCln.Clear();
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        DataRow dtRow = dt.Rows[i];
        //        CityCln.Add(new KeyValuePair<string, string>(dtRow[0].ToString(), dtRow[1].ToString()));
        //    }
        //}
        private void LoadAllIndicators()
        {
            MyDBOperator adoForGetAllIndicatorsName = MyDBOperator.DBOperatorInstance;
            //List<string> ListStrForAllIndicatorsName = new List<string>();
            //for (int i = 0; i < ArrStrAllIndicatorsBeShowedOfA406.Length; i++)
            //{
            //    ListStrForAllIndicatorsName.Add($"[{ArrStrAllIndicatorsBeShowedOfA406[i]}]");
            //}
            //string strAllIndicatorsNameJoin = string.Join(",", ListStrForAllIndicatorsName);
            //string sqlForGetAllIndicatorsName = $"select {strAllIndicatorsNameJoin} from {WithYSA406NameNow}";
            string sqlForGetAllIndicatorsName = "select  [生猪存栏头数（含未断奶小猪）01],[能繁殖的母猪存栏头数02],[生猪出栏头数03]," +
                "[牛存栏头数04],[良种及改良种乳牛存栏头数05],[牛出栏头数06],[羊存栏只数07],[羊出栏只数08],[家禽存栏只数09],[家禽出栏只数10]" +
                ",[兔存栏只数11],[兔出栏只数12],[肉类产量13],[猪肉产量（吨）14],[牛肉产量（吨）15],[羊肉产量（吨）16],[禽肉产量（吨）17]" +
                ",[兔肉产量（吨）18],[其他肉产量（吨）19],[鸡鸭鹅蛋产量（吨）20],[生牛奶产量（吨）21],[蚕茧产量（吨）22],[鸡存栏只数23]" +
                $",[鸡出栏只数24] from {WithYSA406NameNow}";
            try
            {
                DataTable dt = adoForGetAllIndicatorsName.GetDataTable(sqlForGetAllIndicatorsName);
                IndicatorCln.Clear();
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    IndicatorCln.Add(new KeyValuePair<string, string>(i.ToString(), dt.Columns[i].ColumnName.ToString()));
                }
                SelectedIndicator = IndicatorCln[0];
            }
            catch (Exception)
            {
                IndicatorCln.Clear();
                IndicatorCln.Add(new KeyValuePair<string, string>("0", "未导入406表或A406表导入错误"));
                return;
            }


        }


        #endregion

        #region MassPigMsgs和SingleIndicatorPigMsgs
        private ObservableCollection<A406WithMassMsgs> _a406WithMassCln = new ObservableCollection<A406WithMassMsgs>();

        public ObservableCollection<A406WithMassMsgs> A406WithMassCln
        {
            get { return _a406WithMassCln; }
            set { SetProperty(ref _a406WithMassCln, value); }
        }
        private ObservableCollection<SingleIndicatorA406Msg> _singleIndicatorA406Cln = new ObservableCollection<SingleIndicatorA406Msg>();

        public ObservableCollection<SingleIndicatorA406Msg> SingleIndicatorA406Cln
        {
            get { return _singleIndicatorA406Cln; }
            set { _singleIndicatorA406Cln = value; }
        }

        #endregion

        #region 命令调用的方法



        private async Task ShowAllMsgsAsync()
        {
            try
            {
                if (SelectedCity.Value == null || SelectedCountry.Value == null)
                {
                    await MyMessagebox.ShowAsyncInMainWindow("市、县至少有一个下拉框未选择内容!", MsBox.Avalonia.Enums.Icon.Error);
                    return;

                }

                if (this.SelectedPeriod == null)
                {
                    await MyMessagebox.ShowAsyncInMainWindow("请先选择要展示的时期!", MsBox.Avalonia.Enums.Icon.Error);
                    return;
                }
                else if (this.SelectedPeriod.Equals("本季度"))
                {
                    await ShowThisSeasonAsync();
                }
                else//如果用户选择了1到本季度
                {
                    if (Global.IntSeasonNow == 2)
                    {
                        //先判断一下406表是否存在,没有这些表,是无法进行下步操作的
                        string[] allNeed406Tables = new string[] { WithYSA406NameNow, WithYSA406NamePre };
                        MyDBOperator myDBOperator = MyDBOperator.DBOperatorInstance;
                        string NotExistA406TablesNamesJoin = null;
                    List<string> unExistA406Tables =    GetNotExistTablesListAndJoin(allNeed406Tables, out NotExistA406TablesNamesJoin);
                        if (unExistA406Tables != null&& unExistA406Tables.Count>0)
                        { 
                            await MyMessagebox.ShowAsyncInMainWindow(NotExistA406TablesNamesJoin.Substring(1) + "不存在,请先导入!",
                                Icon.Error);
                            return;
                        }
                        //下面的表,有缺失倒是没关系,只是会影响规模户数据与全面数据的比对
                        string WithYearSeasonA209NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                        string WithYearSeasonA210NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                        string WithYearSeasonA211NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                        string WithYearSeasonA212NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                        string WithYearSeasonA209NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                        string WithYearSeasonA210NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                        string WithYearSeasonA211NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                        string WithYearSeasonA212NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";


                        string[] allNeedMassTables = new string[] {WithYearSeasonA209NameNow,WithYearSeasonA209NamePre,WithYearSeasonA210NameNow,WithYearSeasonA210NamePre,
                    WithYearSeasonA211NameNow,WithYearSeasonA211NamePre,WithYearSeasonA212NameNow,WithYearSeasonA212NamePre};
                       
                        
                        string allNotExistMassTablesJoin = null;
                        var notExistMassTablesList = GetNotExistTablesListAndJoin(allNeedMassTables, out allNotExistMassTablesJoin);
                        IEnumerable<string> existsTables;
                        if (notExistMassTablesList != null && notExistMassTablesList.Count>0)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow(allNotExistMassTablesJoin + "不存在请导入,若无此畜种规模户请忽略", Icon.Warning);
                            existsTables = allNeedMassTables.Except(notExistMassTablesList);
                        }
                        else
                        {
                            existsTables = allNeedMassTables;
                        }
                        IEnumerable<string> definiteExistTables  =existsTables.Concat(allNeed406Tables);
                        //只要A406表存在,就先进行修正再进行合并
                        MyProgressBar _progressBar = new MyProgressBar();
                        _progressBar.Show();
                        var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                        string modifyOutcome = await Task.Run(() => Modify.ModifyTables(definiteExistTables, progress));//这里把406表和其他畜种的表要一起修正
                        _progressBar.Close();
                        if (modifyOutcome != null )
                        {
                            await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                        }
                      await  ShowThisYearAsync(definiteExistTables, 2);
                    }
                    else if (Global.IntSeasonNow == 3)
                    {
                        //先判断一下406表是否存在,没有这些表,是无法进行下步操作的
                        string[] allNeedA406Tables = new string[] { WithYSA406NameNow, WithYSA406NamePre,WithYSA406NameSpring };
                        MyDBOperator myDBOperator = MyDBOperator.DBOperatorInstance;
                        string NotExistA406TablesNamesJoin = null;
                        List<string> unExistA406Tables = GetNotExistTablesListAndJoin(allNeedA406Tables, out NotExistA406TablesNamesJoin);
                        if (unExistA406Tables != null && unExistA406Tables.Count>0)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow(NotExistA406TablesNamesJoin.Substring(1) + "不存在,请先导入!",
                                Icon.Error);
                            return;
                        }
                        //下面的表,有缺失倒是没关系,只是会影响规模户数据与全面数据的比对
                        string WithYearSeasonA209NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                        string WithYearSeasonA210NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                        string WithYearSeasonA211NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                        string WithYearSeasonA212NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                        string WithYearSeasonA209NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                        string WithYearSeasonA210NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                        string WithYearSeasonA211NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                        string WithYearSeasonA212NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                        string WithYearSeasonA209NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A209";
                        string WithYearSeasonA210NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A210";
                        string WithYearSeasonA211NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A211";
                        string WithYearSeasonA212NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A212";

                        string[] allNeedMassTables = new string[] {WithYearSeasonA209NameNow,WithYearSeasonA209NamePre,WithYearSeasonA210NameNow,WithYearSeasonA210NamePre,
                        WithYearSeasonA211NameNow,WithYearSeasonA211NamePre,WithYearSeasonA212NameNow,WithYearSeasonA212NamePre,WithYearSeasonA209NameSpring,WithYearSeasonA210NameSpring,
                        WithYearSeasonA211NameSpring,WithYearSeasonA212NameSpring};


                        string allNotExistMassTablesJoin = null;
                        var notExistMassTablesList = GetNotExistTablesListAndJoin(allNeedMassTables, out allNotExistMassTablesJoin);
                        IEnumerable<string> existsMassTables;
                        if (notExistMassTablesList != null && notExistMassTablesList.Count > 0)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow(allNotExistMassTablesJoin + "不存在请导入,若无此畜种规模户请忽略", Icon.Warning);
                            existsMassTables = allNeedMassTables.Except(notExistMassTablesList);
                        }
                        else
                        {
                            existsMassTables = allNeedMassTables;
                        }
                        IEnumerable<string> definiteExistTables = existsMassTables.Concat(allNeedA406Tables);
                        //只要A406表存在,就先进行修正再进行合并
                        MyProgressBar _progressBar = new MyProgressBar();
                        _progressBar.Show();
                        var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                        string modifyOutcome = await Task.Run(() => Modify.ModifyTables(definiteExistTables, progress));//这里把406表和其他畜种的表要一起修正
                        _progressBar.Close();
                        if (modifyOutcome != null)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                        }
                        await ShowThisYearAsync(definiteExistTables, 3);

                    }
                    else //四季度
                    {
                        //先判断一下406表是否存在,没有这些表,是无法进行下步操作的
                        string[] allNeedA406Tables = new string[] { WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameSpring, WithYSA406NameSummer };
                        MyDBOperator myDBOperator = MyDBOperator.DBOperatorInstance;
                        string NotExistA406TablesNamesJoin = null;
                        List<string> unExistA406Tables = GetNotExistTablesListAndJoin(allNeedA406Tables, out NotExistA406TablesNamesJoin);
                        if (unExistA406Tables != null && unExistA406Tables.Count > 0)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow(NotExistA406TablesNamesJoin.Substring(1) + "不存在,请先导入!",
                                Icon.Error);
                            return;
                        }
                        //下面的表,有缺失倒是没关系,只是会影响规模户数据与全面数据的比对
                        string WithYearSeasonA209NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                        string WithYearSeasonA210NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                        string WithYearSeasonA211NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                        string WithYearSeasonA212NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                        string WithYearSeasonA209NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                        string WithYearSeasonA210NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                        string WithYearSeasonA211NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                        string WithYearSeasonA212NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                        string WithYearSeasonA209NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A209";
                        string WithYearSeasonA210NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A210";
                        string WithYearSeasonA211NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A211";
                        string WithYearSeasonA212NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A212";
                        string WithYearSeasonA209NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A209";
                        string WithYearSeasonA210NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A210";
                        string WithYearSeasonA211NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A211";
                        string WithYearSeasonA212NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A212";

                        string[] allNeedMassTables = new string[] {WithYearSeasonA209NameNow,WithYearSeasonA209NamePre,WithYearSeasonA210NameNow,WithYearSeasonA210NamePre,
                    WithYearSeasonA211NameNow,WithYearSeasonA211NamePre,WithYearSeasonA212NameNow,WithYearSeasonA212NamePre,
                        WithYearSeasonA209NameSpring,WithYearSeasonA210NameSpring,WithYearSeasonA211NameSpring,WithYearSeasonA212NameSpring,
                         WithYearSeasonA209NameSummer,WithYearSeasonA210NameSummer,WithYearSeasonA211NameSummer,WithYearSeasonA212NameSummer,
                       };


                        string allNotExistMassTablesJoin = null;
                        var notExistMassTablesList = GetNotExistTablesListAndJoin(allNeedMassTables, out allNotExistMassTablesJoin);
                        IEnumerable<string> existsMassTables;
                        if (notExistMassTablesList != null && notExistMassTablesList.Count>0)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow(allNotExistMassTablesJoin + "不存在请导入,若无此畜种规模户请忽略", Icon.Warning);
                            existsMassTables = allNeedMassTables.Except(notExistMassTablesList);
                        }
                        else
                        {
                            existsMassTables = allNeedMassTables;
                        }
                        IEnumerable<string> definiteExistTables = existsMassTables.Concat(allNeedA406Tables);
                        //只要A406表存在,就先进行修正再进行合并
                        MyProgressBar _progressBar = new MyProgressBar();
                        _progressBar.Show();
                        var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                        string modifyOutcome = await Task.Run(() => Modify.ModifyTables(definiteExistTables, progress));//这里把406表和其他畜种的表要一起修正
                        _progressBar.Close();
                        if (modifyOutcome != null)
                        {
                            await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                        }
                        await ShowThisYearAsync(definiteExistTables, 4);






                        //    保留一下,万一有错可以回来查看
                        //    string[] needAll406Tables = new string[] { WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameSpring, WithYSA406NameSummer };
                        //    MyDBOperator myDBOperator = MyDBOperator.DBOperatorInstance;
                        //    List<string> notExistsA406Tables = myDBOperator.CheckTablesExist(needAll406Tables);
                        //    string allNotExistsA406TablesJoin = null;
                        //    if (notExistsA406Tables.Count > 0)
                        //    {
                        //        foreach (var notExistsTable in notExistsA406Tables)
                        //        {
                        //            allNotExistsA406TablesJoin += $"、{notExistsTable}";
                        //        }

                        //        await MyMessagebox.ShowAsyncInMainWindow(allNotExistsA406TablesJoin.Substring(1) + "不存在,请先导入!",
                        //            Icon.Error);
                        //        return;
                        //    }
                        //    //先判断一下表是否存在
                        //    string WithYearSeasonA209NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                        //    string WithYearSeasonA210NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                        //    string WithYearSeasonA211NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                        //    string WithYearSeasonA212NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                        //    string WithYearSeasonA209NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                        //    string WithYearSeasonA210NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                        //    string WithYearSeasonA211NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                        //    string WithYearSeasonA212NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                        //    string WithYearSeasonA209NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A209";
                        //    string WithYearSeasonA210NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A210";
                        //    string WithYearSeasonA211NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A211";
                        //    string WithYearSeasonA212NameSummer = SummerPlatform + Global.StrYearNow + "第二季度A212";
                        //    string WithYearSeasonA209NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A209";
                        //    string WithYearSeasonA210NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A210";
                        //    string WithYearSeasonA211NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A211";
                        //    string WithYearSeasonA212NameSpring = SpringPlatform + Global.StrYearNow + "第一季度A212";


                        //    string[] allNeedTables = new string[] {WithYearSeasonA209NameNow,WithYearSeasonA209NamePre,WithYearSeasonA210NameNow,WithYearSeasonA210NamePre,
                        //WithYearSeasonA211NameNow,WithYearSeasonA211NamePre,WithYearSeasonA212NameNow,WithYearSeasonA212NamePre,
                        //    WithYearSeasonA209NameSpring,WithYearSeasonA210NameSpring,WithYearSeasonA211NameSpring,WithYearSeasonA212NameSpring,
                        //     WithYearSeasonA209NameSummer,WithYearSeasonA210NameSummer,WithYearSeasonA211NameSummer,WithYearSeasonA212NameSummer,
                        //   };

                        //    var notExistTables = myDBOperator.CheckTablesExist(allNeedTables);
                        //    string allNotExistTablesJoin = null;
                        //    List<string> needBeModifyTableNames = allNeedTables.ToList();
                        //    List<string> list_AllNotExistTables = new List<string>();
                        //    if (notExistTables.Count > 0)
                        //    {
                        //        for (int i = 0; i < notExistTables.Count; i++)
                        //        {
                        //            allNotExistTablesJoin += $"、{notExistTables[i]}";
                        //            list_AllNotExistTables.Add(notExistTables[i]);

                        //        }
                        //        allNotExistTablesJoin = allNotExistTablesJoin.Substring(1);
                        //        await MyMessagebox.ShowAsyncInMainWindow(allNotExistTablesJoin + "不存在请导入,若无此畜种规模户请忽略", Icon.Warning);
                        //        needBeModifyTableNames = needBeModifyTableNames.Except(list_AllNotExistTables).ToList();
                        //    }

                        //    //如果没有缺失,需要先进行修正再进行合并
                        //    MyProgressBar _progressBar = new MyProgressBar();
                        //    _progressBar.Show();
                        //    var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                        //    string modifyOutcome = await Task.Run(() => Modify.ModifyTables(needBeModifyTableNames.Concat(needAll406Tables), progress));
                        //    _progressBar.Close();
                        //    if (modifyOutcome != null)
                        //    {
                        //        await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                        //    }
                        //   await ShowThisYearAsync(needBeModifyTableNames.Concat(needAll406Tables).ToArray(), 4);
                    }
                }



            }
            catch (Exception ex)
            { StaticLogger.SystemError($"出现错误,错误信息{ex.Message},{Environment.NewLine}堆栈为{ex.StackTrace},{Environment.NewLine}对象为{ex.Source},{Environment.NewLine}方法为{ex.TargetSite}"); 
            await MyMessagebox.ShowAsyncInMainWindow($"出现错误,错误信息为{ex.Message}",Icon.Error);
            }

        }
        private List<string> GetNotExistTablesListAndJoin(IEnumerable<string> tables,out string notExistTablesNamesJoin)
        {
            MyDBOperator myDBOperator = MyDBOperator.DBOperatorInstance;
            var notExistTablesList = myDBOperator.CheckTablesExist(tables);
            
            if (notExistTablesList!=null&& notExistTablesList.Count>0)
            {
                notExistTablesNamesJoin = GetAllTableNamesJoin(notExistTablesList);
            }
            else
            {
                notExistTablesNamesJoin = null;
            }
            return notExistTablesList;
        }
        private string GetAllTableNamesJoin(IEnumerable<string> tables)
        {
            var tablesList = tables.ToList();
            string allTableNamesJoin = null;
            for (int i = 0; i < tablesList.Count; i++)
            {
                allTableNamesJoin +="、"+ tablesList[i];
            }
            return allTableNamesJoin.Substring(1);
        }
        private async Task ShowThisYearAsync(IEnumerable<string> allNeedTables, int 期别季)
        {
            try
            {
                A406WithMassCln.Clear();
                MyProgressBar _progressBar = new MyProgressBar();
                _progressBar.Show();
                var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                DTAll = await Task.Run(() =>showA406Msg.GetAll406MsgThisYear(SelectedCity, SelectedCountry, allNeedTables, 期别季,progress));
                _progressBar.Close();
               // DTAll = showA406Msg.GetAll406MsgThisYear(SelectedCity, SelectedCountry, allNeedTables, 期别季);
                if (DTAll != null)
                {
                    A406WithMassCln.Clear();
                    for (int i = 0; i < DTAll.Rows.Count; i++)
                    {
                        DataRow row = DTAll.Rows[i];
                        var 地区 = row[0].ToString();
                        var 地区代码 = row[1].ToString();
                        var 生猪存栏1 = Convert.ToDouble(row.IsNull(2) ? 0 : row[2]);
                        var 能繁母猪存栏2 = Convert.ToDouble(row.IsNull(3) ? 0 : row[3]);
                        var 生猪出栏3 = Convert.ToDouble(row.IsNull(4) ? 0 : row[4]);
                        var 牛存栏4 = Convert.ToDouble(row.IsNull(5) ? 0 : row[5]);
                        var 奶牛存栏5 = Convert.ToDouble(row.IsNull(6) ? 0 : row[6]);
                        var 牛出栏6 = Convert.ToDouble(row.IsNull(7) ? 0 : row[7]);
                        var 羊存栏7 = Convert.ToDouble(row.IsNull(8) ? 0 : row[8]);
                        var 羊出栏8 = Convert.ToDouble(row.IsNull(9) ? 0 : row[9]);
                        var 家禽存栏9 = Convert.ToDouble(row.IsNull(10) ? 0 : row[10]);
                        var 家禽出栏10 = Convert.ToDouble(row.IsNull(11) ? 0 : row[11]);
                        var 兔存栏11 = Convert.ToDouble(row.IsNull(12) ? 0 : row[12]);
                        var 兔出栏12 = Convert.ToDouble(row.IsNull(13) ? 0 : row[13]);

                        var 肉产量13 = Convert.ToDouble(row.IsNull(14) ? 0 : row[14]);
                        var 猪肉产量14 = Convert.ToDouble(row.IsNull(15) ? 0 : row[15]);
                        var 牛肉产量15 = Convert.ToDouble(row.IsNull(16) ? 0 : row[16]);
                        var 羊肉产量16 = Convert.ToDouble(row.IsNull(17) ? 0 : row[17]);
                        var 禽肉产量17 = Convert.ToDouble(row.IsNull(18) ? 0 : row[18]);
                        var 兔肉产量18 = Convert.ToDouble(row.IsNull(19) ? 0 : row[19]);
                        var 其他肉产量19 = Convert.ToDouble(row.IsNull(20) ? 0 : row[20]);

                        var 鸡鸭鹅蛋20 = Convert.ToDouble(row.IsNull(21) ? 0 : row[21]);
                        var 牛奶产量21 = Convert.ToDouble(row.IsNull(22) ? 0 : row[22]);
                        var 蚕茧产量22 = Convert.ToDouble(row.IsNull(23) ? 0 : row[23]);
                        var 鸡存栏 = Convert.ToDouble(row.IsNull(24) ? 0 : row[24]);
                        var 鸡出栏 = Convert.ToDouble(row.IsNull(25) ? 0 : row[25]);


                        A406WithMassMsgs a406Msg = new A406WithMassMsgs(地区, 地区代码, 生猪存栏1, 能繁母猪存栏2, 生猪出栏3, 牛存栏4, 奶牛存栏5, 牛出栏6, 羊存栏7, 羊出栏8, 家禽存栏9, 家禽出栏10
                            , 兔存栏11, 兔出栏12, 肉产量13, 猪肉产量14, 牛肉产量15, 羊肉产量16, 禽肉产量17, 兔肉产量18, 其他肉产量19, 鸡鸭鹅蛋20, 牛奶产量21, 蚕茧产量22, 鸡存栏, 鸡出栏);

                        A406WithMassCln.Add(a406Msg);
                    }
                }
            }
            catch (Exception ex )
            {
                StaticLogger.SystemError($"出现错误,错误信息{ex.Message},{Environment.NewLine}堆栈为{ex.StackTrace},{Environment.NewLine}对象为{ex.Source},{Environment.NewLine}方法为{ex.TargetSite}");
                throw;
            }
        }

        private async Task ShowThisSeasonAsync()
        {
            try
            {
                //A406表是否存在不用判断,如果不存在,是无法执行本方法的,因为连下拉框都无法选择
                MyDBOperator myDbOperator = MyDBOperator.DBOperatorInstance;
               
                //先判断一下是否有表缺失
                string WithYearSeasonA209Name = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                string WithYearSeasonA210Name = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                string WithYearSeasonA211Name = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                string WithYearSeasonA212Name = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                string[] allA406ShowAllMsgNeedTables = new string[] {  WithYearSeasonA209Name, WithYearSeasonA210Name, WithYearSeasonA211Name, WithYearSeasonA212Name };
                string allNotExistTableJoin = null;
              List<string> notExistTableList=  GetNotExistTablesListAndJoin(allA406ShowAllMsgNeedTables, out allNotExistTableJoin);
                IEnumerable<string> existsTables;
                if (notExistTableList!=null && notExistTableList.Count>0)
                {
                    await MyMessagebox.ShowAsyncInMainWindow(allNotExistTableJoin + "不存在请导入,如无本畜种规模户请忽略", Icon.Warning);
                    existsTables = allA406ShowAllMsgNeedTables.Except(notExistTableList);
                }
                else
                {
                    existsTables = allA406ShowAllMsgNeedTables;
                }
                //先修正


                IEnumerable<string> definiteExistTables = existsTables.Concat(new string[] { WithYSA406NameNow });

                MyProgressBar _progressBar = new MyProgressBar();
                _progressBar.Show();
                var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                string modifyOutcome = await Task.Run(() => Modify.ModifyTables(definiteExistTables, progress));//这里把406表和其他畜种的表要一起修正
                _progressBar.Close();
                if (modifyOutcome != null)
                {
                    await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                }


                //如果全部存在,

                DTAll = showA406Msg.GetAll406MsgThisSeason(SelectedCity, SelectedCountry, WithYSA406NameNow);
                if (DTAll != null)
                {
                    A406WithMassCln.Clear();
                    for (int i = 0; i < DTAll.Rows.Count; i++)
                    {
                        DataRow row = DTAll.Rows[i];
                        var 地区 = row[0].ToString();
                        var 地区代码 = row[1].ToString();
                        var 生猪存栏1 = Convert.ToDouble(row.IsNull(2) ? 0 : row[2]);
                        var 能繁母猪存栏2 = Convert.ToDouble(row.IsNull(3) ? 0 : row[3]);
                        var 生猪出栏3 = Convert.ToDouble(row.IsNull(4) ? 0 : row[4]);
                        var 牛存栏4 = Convert.ToDouble(row.IsNull(5) ? 0 : row[5]);
                        var 奶牛存栏5 = Convert.ToDouble(row.IsNull(6) ? 0 : row[6]);
                        var 牛出栏6 = Convert.ToDouble(row.IsNull(7) ? 0 : row[7]);
                        var 羊存栏7 = Convert.ToDouble(row.IsNull(8) ? 0 : row[8]);
                        var 羊出栏8 = Convert.ToDouble(row.IsNull(9) ? 0 : row[9]);
                        var 家禽存栏9 = Convert.ToDouble(row.IsNull(10) ? 0 : row[10]);
                        var 家禽出栏10 = Convert.ToDouble(row.IsNull(11) ? 0 : row[11]);
                        var 兔存栏11 = Convert.ToDouble(row.IsNull(12) ? 0 : row[12]);
                        var 兔出栏12 = Convert.ToDouble(row.IsNull(13) ? 0 : row[13]);

                        var 肉产量13 = Convert.ToDouble(row.IsNull(14) ? 0 : row[14]);
                        var 猪肉产量14 = Convert.ToDouble(row.IsNull(15) ? 0 : row[15]);
                        var 牛肉产量15 = Convert.ToDouble(row.IsNull(16) ? 0 : row[16]);
                        var 羊肉产量16 = Convert.ToDouble(row.IsNull(17) ? 0 : row[17]);
                        var 禽肉产量17 = Convert.ToDouble(row.IsNull(18) ? 0 : row[18]);
                        var 兔肉产量18 = Convert.ToDouble(row.IsNull(19) ? 0 : row[19]);
                        var 其他肉产量19 = Convert.ToDouble(row.IsNull(20) ? 0 : row[20]);

                        var 鸡鸭鹅蛋20 = Convert.ToDouble(row.IsNull(21) ? 0 : row[21]);
                        var 牛奶产量21 = Convert.ToDouble(row.IsNull(22) ? 0 : row[22]);
                        var 蚕茧产量22 = Convert.ToDouble(row.IsNull(23) ? 0 : row[23]);
                        var 鸡存栏 = Convert.ToDouble(row.IsNull(24) ? 0 : row[24]);
                        var 鸡出栏 = Convert.ToDouble(row.IsNull(25) ? 0 : row[25]);


                        A406WithMassMsgs a406Msg = new A406WithMassMsgs(地区, 地区代码, 生猪存栏1, 能繁母猪存栏2, 生猪出栏3, 牛存栏4, 奶牛存栏5, 牛出栏6, 羊存栏7, 羊出栏8, 家禽存栏9, 家禽出栏10
                            , 兔存栏11, 兔出栏12, 肉产量13, 猪肉产量14, 牛肉产量15, 羊肉产量16, 禽肉产量17, 兔肉产量18, 其他肉产量19, 鸡鸭鹅蛋20, 牛奶产量21, 蚕茧产量22, 鸡存栏, 鸡出栏);

                        A406WithMassCln.Add(a406Msg);
                    }
                }
            }
            catch (Exception ex)
            {
                StaticLogger.SystemError($"出现错误,错误信息{ex.Message},{Environment.NewLine}堆栈为{ex.StackTrace},{Environment.NewLine}对象为{ex.Source},{Environment.NewLine}方法为{ex.TargetSite}");
                throw;
            }

        }


        private async Task ShowSingleMsgAsync()
        {
            try
            {
                if (SelectedCity.Value == null || SelectedCountry.Value == null)
                {
                    await MyMessagebox.ShowAsyncInMainWindow("市、县至少有一个下拉框未选择内容!", MsBox.Avalonia.Enums.Icon.Error);
                    return;
                }
                if (string.IsNullOrEmpty(SelectedIndicator.Value))
                {
                    await MyMessagebox.ShowAsyncInMainWindow("未选择具体指标名称!", MsBox.Avalonia.Enums.Icon.Error);

                    return;
                }

                //先确定一下本季度\上季度\同比季度的A406表是否存在
                string[] allNeedA406Tables = new[]
                {
                    WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameYOY,
                };
                var myDBOperator = MyDBOperator.DBOperatorInstance;
                string notExistA406TablesJoin = null;
                var notExistA406Tables = GetNotExistTablesListAndJoin(allNeedA406Tables, out notExistA406TablesJoin);
                if (notExistA406Tables.Count>0)
                {
                    await MyMessagebox.ShowAsyncInMainWindow($"{notExistA406TablesJoin}不存在,请先导入!", MsBox.Avalonia.Enums.Icon.Error);
                    return;
                }
                //先判断一下是否有表缺失
                string WithYearSeasonA209NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A209";
                string WithYearSeasonA210NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A210";
                string WithYearSeasonA211NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A211";
                string WithYearSeasonA212NameNow = Global.PlatformNow + Global.StrYearNow + Global.StrSeasonNow + "A212";
                string WithYearSeasonA209NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A209";
                string WithYearSeasonA210NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A210";
                string WithYearSeasonA211NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A211";
                string WithYearSeasonA212NamePre = Global.PlatformPre + Global.StrYearPre + Global.StrSeasonPre + "A212";
                string WithYearSeasonA209NameYOY = Global.PlatformYOY + Global.StrYearYOY + Global.StrSeasonYOY + "A209";
                string WithYearSeasonA210NameYOY = Global.PlatformYOY + Global.StrYearYOY + Global.StrSeasonYOY + "A210";
                string WithYearSeasonA211NameYOY = Global.PlatformYOY + Global.StrYearYOY + Global.StrSeasonYOY + "A211";
                string WithYearSeasonA212NameYOY = Global.PlatformYOY + Global.StrYearYOY + Global.StrSeasonYOY + "A212";
                //allNeedTables变量名改一下
                string[] allNeedMassTables = new string[] { 
                WithYearSeasonA209NameNow,WithYearSeasonA209NamePre,WithYearSeasonA209NameYOY,
                WithYearSeasonA210NameNow,WithYearSeasonA210NamePre,WithYearSeasonA210NameYOY,
                WithYearSeasonA211NameNow,WithYearSeasonA211NamePre,WithYearSeasonA211NameYOY,
                WithYearSeasonA212NameNow,WithYearSeasonA212NamePre,WithYearSeasonA212NameYOY,
                };
                string notExitsMassTablesJoin = null;
                var notExistTablesList = GetNotExistTablesListAndJoin(allNeedMassTables, out notExitsMassTablesJoin);
              IEnumerable<string> existsMassTables;
              if (notExistTablesList != null && notExistTablesList.Count > 0)
              {
                  await MyMessagebox.ShowAsyncInMainWindow(notExitsMassTablesJoin + "不存在请导入,若无此畜种规模户请忽略", Icon.Warning);
                    existsMassTables = allNeedMassTables.Except(notExistTablesList);
              }
              else
              {
                    existsMassTables = allNeedMassTables;
              }
              IEnumerable<string> definiteExistTables = existsMassTables.Concat(allNeedA406Tables);


               
                //修正一下 
                MyProgressBar _progressBar = new MyProgressBar();
                _progressBar.Show();
                var progress = new Progress<int>(value => _progressBar.UpdateProgress(value));
                string modifyOutcome = await Task.Run(() => Modify.ModifyTables(definiteExistTables, progress));
                _progressBar.Close();
                if (modifyOutcome != null)
                {
                    await MyMessagebox.ShowAsyncInMainWindow($"市县乡名称修正时出错,错误内容为:{modifyOutcome},一般不影响数据展示,建议排查", Icon.Warning);
                }
                DTForSingleIndicator = showA406Msg.GetSingleA406Msg(SelectedCity, SelectedCountry, SelectedIndicator, WithYSA406NameNow, WithYSA406NamePre, WithYSA406NameYOY);
                if (DTForSingleIndicator.Columns.Count > 22) //说明有规模户对比数据,25条
                {
                    SingleIndicatorA406Cln.Clear();
                    for (int i = 0; i < DTForSingleIndicator.Rows.Count; i++)
                    {
                        DataRow row = DTForSingleIndicator.Rows[i];
                        // 使用 Convert.IsDBNull 检查并提供默认值
                        var 地区名称 = row.Field<string>(0) ?? "未知";
                        var 地区编码 = row.Field<string>(1) ?? "未知";

                        // 使用 Convert.ToDouble 并处理可能的 null 值
                        var 当季指标值 = Convert.ToDouble(row.IsNull(2) ? 0 : row[2]);
                        var 上季指标值 = Convert.ToDouble(row.IsNull(3) ? 0 : row[3]);
                        var 同比季度指标值 = Convert.ToDouble(row.IsNull(4) ? 0 : row[4]);
                        var 环比增量 = Convert.ToDouble(row.IsNull(5) ? 0 : row[5]);
                        var 同比增量 = Convert.ToDouble(row.IsNull(6) ? 0 : row[6]);
                        var 环比增幅 = Convert.ToDouble(row.IsNull(7) ? 0 : row[7]);
                        var 同比增幅 = Convert.ToDouble(row.IsNull(8) ? 0 : row[8]);
                        var 本季规模户数据 = Convert.ToDouble(row.IsNull(9) ? 0 : row[9]);
                        var 上季规模户数据 = Convert.ToDouble(row.IsNull(10) ? 0 : row[10]);
                        var 同比季度规模户数据 = Convert.ToDouble(row.IsNull(11) ? 0 : row[11]);

                        var 当季占比 = Convert.ToDouble(row.IsNull(12) ? 0 : row[12]);
                        var 上季占比 = Convert.ToDouble(row.IsNull(13) ? 0 : row[13]);
                        var 同比季度占比 = Convert.ToDouble(row.IsNull(14) ? 0 : row[14]);

                        var 当季散户量 = Convert.ToDouble(row.IsNull(15) ? 0 : row[15]);
                        var 上季散户量 = Convert.ToDouble(row.IsNull(16) ? 0 : row[16]);
                        var 同比散户量 = Convert.ToDouble(row.IsNull(17) ? 0 : row[17]);


                        var 当季散户率= Convert.ToDouble(row.IsNull(18) ? 0 : row[18]);
                        var 上季散户率 = Convert.ToDouble(row.IsNull(19) ? 0 : row[19]);
                        var 同比散户率 = Convert.ToDouble(row.IsNull(20) ? 0 : row[20]);
                        var 散户环比增量 = Convert.ToDouble(row.IsNull(21) ? 0 : row[21]);
                        var 散户同比增量 = Convert.ToDouble(row.IsNull(22) ? 0 : row[22]);
                        var 散户环比增幅 = Convert.ToDouble(row.IsNull(23) ? 0 : row[23]);
                        var 散户同比增幅 = Convert.ToDouble(row.IsNull(24) ? 0 : row[24]);


                        SingleIndicatorA406Cln.Add(new SingleIndicatorA406Msg(地区名称, 地区编码, 当季指标值, 上季指标值,
                            同比季度指标值, 环比增量, 同比增量, 环比增幅, 同比增幅,本季规模户数据,上季规模户数据,同比季度规模户数据, 当季占比, 上季占比, 同比季度占比,
                            当季散户量,上季散户量,同比散户量,当季散户率,上季散户率,同比散户率,散户环比增量,散户同比增量,散户环比增幅,散户同比增幅));
                    }
                }
                else
                {
                    SingleIndicatorA406Cln.Clear();
                    for (int i = 0; i < DTForSingleIndicator.Rows.Count; i++)
                    {
                        DataRow row = DTForSingleIndicator.Rows[i];
                        // 使用 Convert.IsDBNull 检查并提供默认值
                        var 地区名称 = row.Field<string>(0) ?? "未知";
                        var 地区编码 = row.Field<string>(1) ?? "未知";

                        // 使用 Convert.ToDouble 并处理可能的 null 值
                        var 当季指标值 = Convert.ToDouble(row.IsNull(2) ? 0 : row[2]);
                        var 上季指标值 = Convert.ToDouble(row.IsNull(3) ? 0 : row[3]);
                        var 同比季度指标值 = Convert.ToDouble(row.IsNull(4) ? 0 : row[4]);
                        var 环比增量 = Convert.ToDouble(row.IsNull(5) ? 0 : row[5]);
                        var 同比增量 = Convert.ToDouble(row.IsNull(6) ? 0 : row[6]);
                        var 环比增幅 = Convert.ToDouble(row.IsNull(7) ? 0 : row[7]);
                        var 同比增幅 = Convert.ToDouble(row.IsNull(8) ? 0 : row[8]);
                        var 当季占比 = Convert.ToDouble(row.IsNull(9) ? 0 : row[9]);
                        var 上季占比 = Convert.ToDouble(row.IsNull(10) ? 0 : row[10]);
                        var 同比季度占比 = Convert.ToDouble(row.IsNull(11) ? 0 : row[11]);
                        SingleIndicatorA406Cln.Add(new SingleIndicatorA406Msg(地区名称, 地区编码, 当季指标值, 上季指标值,
                            同比季度指标值, 环比增量, 同比增量, 环比增幅, 同比增幅, 当季占比, 上季占比, 同比季度占比));
                    }
                }
                if (DTForSingleIndicator != null && DTForSingleIndicator.Rows.Count > 0)
                {
                   
                    //如果是规模户和A406表都有的数据
                    if (DTForSingleIndicator != null && DTForSingleIndicator.Columns.Count > 22)
                    {
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally = new List<ISeries>();
                        //List<ISeries> CircleConsistOfPiecesOfMassNowConvertToArraryLast = new List<ISeries>();//规模户的去前面四张表看
                        //List<ISeries> CircleConsistOfPiecesOfMassPreConvertToArraryLast = new List<ISeries>();
                        //List<ISeries> CircleConsistOfPiecesOfMassYOYConvertToArraryLast = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfSmallNowConvertToArrayLast = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfSmallPreConvertToArrayLast = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfSmallYOYConvertToArrayLast = new List<ISeries>();
                        List<double> ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast = new List<double>();
                        List<double> ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast = new List<double>();
                        List<double> ListColumnSeriesValuesIncreaseOfSmallPreConvertToArryLast = new List<double>();
                        List<double> ListColumnSeriesValuesIncreaseOfSmallYOYConvertToArryLast = new List<double>();
                        List<double> ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast = new List<double>();
                        List<double> ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast = new List<double>();
                        List<double> ListLineSeriesValuesIncreaseOfSmallPreConvertToArrayLast = new List<double>();
                        List<double> ListLineSeriesValuesIncreaseOfSmallYOYConvertToArrayLast = new List<double>();
                        List<string> ListColumnsWholeXAxisNames = new List<string>();
                        List<string> ListLineWholeXAxisNames = new List<string>();
                        List<string> ListColumnsSmallXAxisNames = new List<string>();
                        List<string> ListLineSmallXAxisNames = new List<string>();
                        string NameInDT = null;
                        string PieTitleName = null;
                        if (SelectedCity.Value.Equals("全部"))
                        {
                            NameInDT = "市";
                            PieTitleName = "分地市";
                        }
                        else if (SelectedCountry.Value.Equals("全部"))//全市的情况
                        {
                            NameInDT = "县";
                            PieTitleName = "分县";
                        }
                        else if (SelectedCountry.Value.Equals("全部") == false)//某个县全县的情况
                        {
                            NameInDT = "乡";
                            PieTitleName = "分乡镇";
                        }

                        for (int i = 0; i < DTForSingleIndicator.Rows.Count - 1; i++)
                        {
                            DataRow Row = base.DTForSingleIndicator.Rows[i];
                            //AddOnePieSeriesToCircle(Row, i % 2, NameInDT, $"本季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"本季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"上季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"同比季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"本季度散户量", ref CircleConsistOfPiecesOfSmallNowConvertToArrayLast);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"上季度散户量", ref CircleConsistOfPiecesOfSmallPreConvertToArrayLast);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"同比季度散户量", ref CircleConsistOfPiecesOfSmallYOYConvertToArrayLast);
                            AddTw0TotalColumsToCart(Row, 0, "环比增量", "同比增量", ref ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast, ref ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast, ref ListColumnsWholeXAxisNames);
                            AddTw0TotalColumsToCart(Row, 0, "环比增幅", "同比增幅", ref ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast, ref ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast, ref ListLineWholeXAxisNames);
                            AddTw0TotalColumsToCart(Row, 0, "散户环比增量", "散户同比增量", ref ListColumnSeriesValuesIncreaseOfSmallPreConvertToArryLast, ref ListColumnSeriesValuesIncreaseOfSmallYOYConvertToArryLast, ref ListColumnsSmallXAxisNames);
                            AddTw0TotalColumsToCart(Row, 0, "散户环比增速(%)", "散户同比增速(%)", ref ListLineSeriesValuesIncreaseOfSmallPreConvertToArrayLast, ref ListLineSeriesValuesIncreaseOfSmallYOYConvertToArrayLast, ref ListLineSmallXAxisNames);
                        }

                        if (CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally.Count > 0)//如果当前季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfNow = CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfNow = SetNullPieSeries();
                            TitleOfPieSeriesNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度全面数据为空");
                        }
                        if (CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally.Count > 0)//如果上季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfPre = CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesPre = base.SetTitleOfPie($"{SelectedIndicator.Value}上季度全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfPre = SetNullPieSeries();
                            TitleOfPieSeriesPre = SetTitleOfPie($"{SelectedIndicator.Value}上季度全面数据为空");
                        }
                        if (CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally.Count > 0)//如果同比季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfYOY = CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfYOY = SetNullPieSeries();
                            TitleOfPieSeriesYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比季度全面数据为空");
                        }
                        //散户的
                        if (CircleConsistOfPiecesOfSmallNowConvertToArrayLast.Count > 0)//如果当前季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfSmallNow = CircleConsistOfPiecesOfSmallNowConvertToArrayLast.ToArray();
                            TitleOfPieSeriesSmallNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度散户数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfSmallNow = SetNullPieSeries();
                            TitleOfPieSeriesSmallNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度散户数据为空");
                        }
                        if (CircleConsistOfPiecesOfSmallPreConvertToArrayLast.Count > 0)
                        {
                            PieSeriesOfSmallPre = CircleConsistOfPiecesOfSmallPreConvertToArrayLast.ToArray();
                            TitleOfPieSeriesSmallPre = SetTitleOfPie($"{SelectedIndicator.Value}上季度散户数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfSmallPre = SetNullPieSeries();
                            TitleOfPieSeriesSmallPre = SetTitleOfPie($"{SelectedIndicator.Value}上季度散户数据为空");
                        }
                        if (CircleConsistOfPiecesOfSmallYOYConvertToArrayLast.Count > 0)//如果当前季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfSmallYOY = CircleConsistOfPiecesOfSmallYOYConvertToArrayLast.ToArray();
                            TitleOfPieSeriesSmallYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比季度散户数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfSmallYOY = SetNullPieSeries();
                            TitleOfPieSeriesSmallYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比季度散户数据为空");
                        }



                        if (ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast.Count > 0)
                        {
                            //直方图标题
                            TitleOfCartNow = GetTitleOfCart($"{SelectedIndicator.Value}全面数据环比和同比增量数据");
                            CartSeriesNow = SetColumnsSeries<double, double>($"{SelectedIndicator.Value}全面环比增量", ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast,
                               $"{SelectedIndicator.Value}同比增量", ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast);
                            CartXAxisOfNow = SetColumnsXAxis($"{PieTitleName}名称", ListColumnsWholeXAxisNames);
                            CartYAxisOfNow = SetColumnsYAxis(SelectedIndicator.Value + "全面增量数据");
                        }
                        else
                        {
                            TitleOfCartNow = GetTitleOfCart($"{SelectedIndicator.Value}环比和同比增量数据无数据");
                            CartXAxisOfNow = SetNullXAxis();
                            CartYAxisOfNow = SetNullYAxis();
                            CartSeriesNow = SetNullColumnsSeries();
                        }
                        if (ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast.Count > 0)
                        {
                            LineTitle = base.SetTitleOfLine(this.SelectedIndicator.Value + PieTitleName + "全面数据增幅图(%)");
                            LineSeries = base.SetLineSeries<double, double>(SelectedIndicator.Value + "全面数据环比增幅", ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast,
                                SelectedIndicator.Value + "同比增幅", ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast);
                            LineXAxis = SetLineXAxis(PieTitleName + "名称", ListLineWholeXAxisNames);
                            LineYAxis = SetLineYAxis(SelectedIndicator.Value + "增幅数据");
                        }

                        else
                        {
                            LineTitle = SetTitleOfLine(this.SelectedIndicator.Value + PieTitleName + "增幅无数据"); ;
                            LineXAxis = SetNullXAxis(); ;
                            LineYAxis = SetNullYAxis();
                            LineSeries = SetNullLineSeries();
                        }

                        //散户直方图
                        if (ListColumnSeriesValuesIncreaseOfSmallPreConvertToArryLast.Count > 0)
                        {
                            TitleOfCartSmallNow = GetTitleOfCart($"{SelectedIndicator.Value}散户数据环比和同比增量数据");
                            CartSeriesSmallNow = SetColumnsSeries<double, double>($"{SelectedIndicator.Value}散户环比增量", ListColumnSeriesValuesIncreaseOfSmallPreConvertToArryLast,
                                                      $"{SelectedIndicator.Value}散户同比增量", ListColumnSeriesValuesIncreaseOfSmallYOYConvertToArryLast);
                            CartXAxisOfSmallNow = SetColumnsXAxis($"{PieTitleName}名称", ListColumnsSmallXAxisNames);
                            CartYAxisOfSmallNow = SetColumnsYAxis(SelectedIndicator.Value + "散户增量数据");
                        }
                        else
                        {
                            TitleOfCartSmallNow = GetTitleOfCart("无数据");
                            CartSeriesSmallNow = SetNullColumnsSeries();
                            CartXAxisOfSmallNow = SetNullXAxis();
                            CartYAxisOfSmallNow = SetNullYAxis();
                        }
                        if (ListLineSeriesValuesIncreaseOfSmallPreConvertToArrayLast.Count > 0)
                        {
                            LineTitleSmall = base.SetTitleOfLine(this.SelectedIndicator.Value + PieTitleName + "散户数据增幅图(%)");
                            LineSeriesSmall = SetLineSeries<double, double>(SelectedIndicator.Value + "散户数据环比增幅", ListLineSeriesValuesIncreaseOfSmallPreConvertToArrayLast,
                                                       SelectedIndicator.Value + "散户数据同比增幅", ListLineSeriesValuesIncreaseOfSmallYOYConvertToArrayLast);
                            LineXAxisSmall = SetLineXAxis(PieTitleName + "名称", ListLineSmallXAxisNames);
                            LineYAxisSmall = SetLineYAxis(SelectedIndicator.Value + "散户增幅数据");
                        }
                        else
                        {
                            LineTitleSmall = GetTitleOfCart("无数据");
                            LineSeriesSmall = SetNullLineSeries();
                            LineXAxisSmall = SetNullXAxis();
                            LineYAxisSmall = SetNullYAxis();

                        }


                    }
                   //如果是规模户没有的数据,如肉产量
                    else// if (DTForSingleIndicator != null && DTForSingleIndicator.Columns.Count <=22)//没有大户的时候,应该怎么展现数据
                    {
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally = new List<ISeries>();
                        List<ISeries> CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally = new List<ISeries>();
                        //List<ISeries> CircleConsistOfPiecesOfMassNowConvertToArraryLast = new List<ISeries>();//规模户的去前面四张表看
                        //List<ISeries> CircleConsistOfPiecesOfMassPreConvertToArraryLast = new List<ISeries>();
                        //List<ISeries> CircleConsistOfPiecesOfMassYOYConvertToArraryLast = new List<ISeries>();

                        List<double> ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast = new List<double>();
                        List<double> ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast = new List<double>();

                        List<double> ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast = new List<double>();
                        List<double> ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast = new List<double>();

                        List<string> ListColumnsWholeXAxisNames = new List<string>();
                        List<string> ListLineWholeXAxisNames = new List<string>();
                        List<string> ListColumnsSmallXAxisNames = new List<string>();
                        List<string> ListLineSmallXAxisNames = new List<string>();
                        string NameInDT = null;
                        string PieTitleName = null;
                        if (SelectedCity.Value.Equals("全部"))
                        {
                            NameInDT = "市";
                            PieTitleName = "分地市";
                        }
                       else if (SelectedCountry.Value.Equals("全部"))//全市的情况
                        {
                            NameInDT = "县";
                            PieTitleName = "分县";
                        }
                        else if (SelectedCountry.Value.Equals("全部") == false)//某个县全县的情况
                        {
                            NameInDT = "乡";
                            PieTitleName = "分乡镇";
                        }

                        for (int i = 0; i < DTForSingleIndicator.Rows.Count - 1; i++)
                        {
                            DataRow Row = base.DTForSingleIndicator.Rows[i];
                            //AddOnePieSeriesToCircle(Row, i % 2, NameInDT, $"本季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"本季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"上季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally);
                            AddOnePieSeriesToCircleList(Row, NameInDT, $"同比季度{SelectedIndicator.Value}", ref CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally);

                            AddTw0TotalColumsToCart(Row, 0, "环比增量", "同比增量", ref ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast, ref ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast, ref ListColumnsWholeXAxisNames);
                            AddTw0TotalColumsToCart(Row, 0, "环比增幅", "同比增幅", ref ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast, ref ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast, ref ListLineWholeXAxisNames);

                        }

                        if (CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally.Count > 0)//如果当前季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfNow = CircleConsistOfPiecesOfIndicatorSeasonNowConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfNow = SetNullPieSeries();
                            TitleOfPieSeriesNow = SetTitleOfPie($"{SelectedIndicator.Value}本季度全面数据为空");
                        }
                        if (CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally.Count > 0)//如果上季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfPre = CircleConsistOfPiecesOfIndicatorSeasonPreConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesPre = base.SetTitleOfPie($"{SelectedIndicator.Value}上季度全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfPre = SetNullPieSeries();
                            TitleOfPieSeriesPre = SetTitleOfPie($"{SelectedIndicator.Value}上季度全面数据为空");
                        }
                        if (CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally.Count > 0)//如果同比季度的数据不为空,就显示到界面上
                        {
                            PieSeriesOfYOY = CircleConsistOfPiecesOfIndicatorSeasonYOYConvertToArrayFinally.ToArray();
                            TitleOfPieSeriesYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比全面数据和比重示意图(%)");
                        }
                        else
                        {
                            PieSeriesOfYOY = SetNullPieSeries();
                            TitleOfPieSeriesYOY = SetTitleOfPie($"{SelectedIndicator.Value}同比季度全面数据为空");
                        }
                        //散户的要清空


                       
                            PieSeriesOfSmallNow = SetNullPieSeries();
                            TitleOfPieSeriesSmallNow = SetTitleOfPie("");

                            PieSeriesOfSmallPre = SetNullPieSeries();
                            TitleOfPieSeriesSmallPre = SetTitleOfPie("");

                            PieSeriesOfSmallYOY = SetNullPieSeries();
                            TitleOfPieSeriesSmallYOY = SetTitleOfPie("");

                            TitleOfCartSmallNow = GetTitleOfCart("");
                            CartSeriesSmallNow = SetNullColumnsSeries();
                            CartXAxisOfSmallNow = SetNullXAxis();
                            CartYAxisOfSmallNow = SetNullYAxis();

                        LineTitleSmall = SetTitleOfLine("");
                        LineSeriesSmall = SetNullLineSeries();
                            LineXAxisSmall = SetNullXAxis();
                        LineYAxisSmall = SetNullYAxis();


                        if (ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast.Count > 0)
                        {
                            //直方图标题
                            TitleOfCartNow = GetTitleOfCart($"{SelectedIndicator.Value}全面数据环比和同比增量数据");
                            CartSeriesNow = SetColumnsSeries<double, double>($"{SelectedIndicator.Value}全面环比增量", ListColumnSeriesValuesIncreaseOfWholePreConvertToArryLast,
                               $"{SelectedIndicator.Value}同比增量", ListColumnSeriesValuesIncreaseOfWholeYOYConvertToArryLast);
                            CartXAxisOfNow = SetColumnsXAxis($"{PieTitleName}名称", ListColumnsWholeXAxisNames);
                            CartYAxisOfNow = SetColumnsYAxis(SelectedIndicator.Value + "全面增量数据");
                        }
                        else
                        {
                            TitleOfCartNow = GetTitleOfCart("");
                            CartXAxisOfNow = SetNullXAxis();
                            CartYAxisOfNow = SetNullYAxis();
                            CartSeriesNow = SetNullColumnsSeries();
                        }
                        if (ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast.Count > 0)
                        {
                            LineTitle = base.SetTitleOfLine(this.SelectedIndicator.Value + PieTitleName + "全面数据增幅图(%)");
                            LineSeries = base.SetLineSeries<double, double>(SelectedIndicator.Value + "全面数据环比增幅", ListLineSeriesValuesIncreaseOfWholePreConvertToArrayLast,
                                SelectedIndicator.Value + "同比增幅", ListLineSeriesValuesIncreaseOfWholeYOYConvertToArrayLast);
                            LineXAxis = SetLineXAxis(PieTitleName + "名称", ListLineWholeXAxisNames);
                            LineYAxis = SetLineYAxis(SelectedIndicator.Value + "增幅数据");
                        }

                        else
                        {
                            LineTitle = SetTitleOfPie("");
                            LineXAxis = SetNullXAxis();
                            LineYAxis = SetNullYAxis();
                            LineSeries = SetNullLineSeries();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                StaticLogger.SystemError($"出现错误,错误信息{ex.Message},{Environment.NewLine}堆栈为{ex.StackTrace},{Environment.NewLine}对象为{ex.Source},{Environment.NewLine}方法为{ex.TargetSite}");
                await MyMessagebox.ShowAsyncInMainWindow($"出现错误,{ex.Message}", Icon.Error);
            }
        }
        #endregion
        #region 

        private async Task ExpertToExcelAll()
        {
            string path = Path.Combine(MyDataFolderOperator.AuditOutcomeFolderPathInAuditProgramFolder, $"A406表{Global.StrYearNow}{Global.StrSeasonNow}{SelectedPeriod}所有指标汇总分析结果{DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒")}.xlsx");
            if (A406WithMassCln != null)
            {
                bool isExpertSuccess = ExpertToExcelHelper.ExportToExcel<A406WithMassMsgs>(A406WithMassCln, path);
                if (isExpertSuccess)
                {
                    await MyMessagebox.ShowAsyncInMainWindow("导出成功,保存在“审核结果“文件夹中”", Icon.Success);
                }
                else
                {
                    await MyMessagebox.ShowAsyncInMainWindow("导出出错", Icon.Error);
                }
            }
            else
            {
                await MyMessagebox.ShowAsyncInMainWindow("未进行分析!", Icon.Error);
            }
        }
        private async Task ExpertToExcelSingle()
        {
            string path = Path.Combine(MyDataFolderOperator.AuditOutcomeFolderPathInAuditProgramFolder, $"A406表{Global.StrYearNow}{Global.StrSeasonNow}{SelectedIndicator.Value}单个指标汇总分析结果{DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒")}.xlsx");
            if (SingleIndicatorA406Cln != null)
            {
                bool isExpertSuccess = ExpertToExcelHelper.ExportToExcel<SingleIndicatorA406Msg>(SingleIndicatorA406Cln, path);
                if (isExpertSuccess)
                {
                    await MyMessagebox.ShowAsyncInMainWindow("导出成功,保存在“审核结果“文件夹中”", Icon.Success);
                }
                else
                {
                    await MyMessagebox.ShowAsyncInMainWindow("导出出错", Icon.Error);
                }
            }
            else
            {
                await MyMessagebox.ShowAsyncInMainWindow("未进行分析!", Icon.Error);
            }
        }
        //private async void ExpertToExcel()
        //{
        //    ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
        //    using (ExcelPackage package = new ExcelPackage())
        //    {

        //        // 获取所有公共属性作为列名
        //        var properties = typeof(A406WithMassMsgs).GetProperties(BindingFlags.Public | BindingFlags.Instance);



        //        // 写入表头
        //        for (int col = 0; col < properties.Length; col++)
        //        {
        //            sht.Cells[1, col + 1].Value = properties[col].Name;
        //        }

        //        // 写入数据行
        //        for (int row = 0; row < A406WithMassCln.Count; row++)
        //        {
        //            var item = A406WithMassCln[row];
        //            for (int col = 0; col < properties.Length; col++)
        //            {
        //                var property = properties[col];
        //                sht.Cells[row + 2, col + 1].Value = property.GetValue(item);
        //            }
        //        }

        //        // 自动调整列宽
        //        sht.Cells.AutoFitColumns();


        //        // 保存文件
        //        FileInfo file = new FileInfo(Path.Combine(MyDataFolderOperator.AuditOutcomeFolderPathInAuditProgramFolder, $"汇总分析结果{DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒")}.xlsx"));
        //        package.SaveAs(file);
        //        await MyMessagebox.ShowAsyncInMainWindow("导出完成,在审核结果文件夹",  Icon.Success);

        //    }
        //}





        //private static readonly Dictionary<Type, PropertyInfo[]> PropertyCache = new Dictionary<Type, PropertyInfo[]>();

        //public static void ExportToExcel(List<A406WithMassMsgs> data, string filePath)
        //{
        //    // 获取属性信息并缓存
        //    var properties = GetCachedProperties(typeof(A406WithMassMsgs));

        //    using (var package = new ExcelPackage())
        //    {
        //        var worksheet = package.Workbook.Worksheets.Add("Data");

        //        // 写入表头
        //        for (int col = 0; col < properties.Length; col++)
        //        {
        //            worksheet.Cells[1, col + 1].Value = properties[col].Name;
        //        }

        //        // 写入数据行
        //        for (int row = 0; row < data.Count; row++)
        //        {
        //            var item = data[row];
        //            for (int col = 0; col < properties.Length; col++)
        //            {
        //                var property = properties[col];
        //                worksheet.Cells[row + 2, col + 1].Value = property.GetValue(item);
        //            }
        //        }

        //        worksheet.Cells.AutoFitColumns();
        //        File.WriteAllBytes(filePath, package.GetAsByteArray());
        //    }
        //}

        //private static PropertyInfo[] GetCachedProperties(Type type)
        //{
        //    if (!PropertyCache.TryGetValue(type, out var properties))
        //    {
        //        properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
        //        PropertyCache[type] = properties;
        //    }
        //    return properties;
        //}
    }



    #endregion
}

